const pkg = require('./package')
const path = require('path')


const NuxtConfig = {
  mode: 'universal',

  /*
   ** Headers of the page
   */
  head: {
    title: pkg.name,
    meta: [{
        charset: 'utf-8'
      },
      {
        name: 'viewport',
        content: 'width=device-width, initial-scale=1'
      },
      {
        hid: 'description',
        name: 'description',
        content: pkg.description
      }
    ],
    link: [{
      rel: 'icon',
      type: 'image/x-icon',
      href: '/favicon.ico'
    }]
  },

  /*
   ** Customize the progress-bar color
   */
  loading: {
    color: '#3b8070'
  },

  /*
  ** Global CSS
  全局 common
  */
  css: [
    'element-ui/lib/theme-chalk/reset.css',
    'element-ui/lib/theme-chalk/index.css',
    '@/assets/css/main.css'
  ],

  /*
   ** Plugins to load before mounting the App
   */
  plugins: [
    '@/plugins/element-ui'
  ],

  /*
   ** Nuxt.js modules
   */
  modules: ['@nuxtjs/axios'], // 不需要加入@nuxtjs/proxy
  /*
   ** Build configuration
   */
  axios: {
    proxy: true,
    prefix: '/', // baseURL
    credentials: true,
  },
  proxy: {
    '/api/': {
      target: 'http://127.0.0.1:2001', // 代理地址
      changeOrigin: true,
      pathRewrite: {
        '^/api': ''
      },
    },
  },
  build: {
    transpile: [/^element-ui/],
    /*
     ** You can extend webpack config here
     */
    extend(config, ctx) {
      // use eslint-loader
     
      // if (ctx.isClient) {
      //   // 添加 alias 配置  没用
      //   // Object.assign(config.resolve.alias, {
      //   //   'css': path.resolve(__dirname, 'assets/css'),
      //   //   'components': path.resolve(__dirname, 'components'),
      //   // })
      //   const alias = config.resolve.alias = config.resolve.alias || {}
       
      //   alias['components'] = path.join(__dirname, 'components')
      //   alias['layouts'] = path.join(__dirname, 'components')
      //   console.log(alias)
      // }
    }
  }
}

module.exports = NuxtConfig 